<?php
/**
 * Created by PhpStorm.
 * User: wodrow
 * Date: 18-12-10
 * Time: 上午10:01
 */

namespace admin\modules\basedata\models;


use common\models\db\Area;
use yii\data\ActiveDataProvider;

class AreaSearch extends Area
{
    public function rules()
    {
        return [
            [['id', 'fid',], 'integer'],
            [['name',], 'safe'],
        ];
    }

    public function search($params)
    {
        $query = self::find();

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'pagination' => [
                'pageSize' => 25,
            ],
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        $query->andFilterWhere([
            'id' => $this->id,
            'fid' => $this->fid,
        ]);

        $query->andFilterWhere(['like', 'name', $this->name]);

        return $dataProvider;
    }
}